package utilities;

import java.io.*;
import java.util.List;

/**
 *
 * @author Atuan
 */
public class PiisWriter {
    public static void write(List<String> input,String filenamePath){
        BufferedWriter bufferedWriter = null;  
//            FileWriter errorsF = null;      
        try {    
            //filename = "src/test1/"+filename;
            // if file doesnt exists, then create it
            File file = new File(filenamePath);
            if (!file.exists()) {
		file.createNewFile();
            }
            //Construct the BufferedWriter object
            bufferedWriter = new BufferedWriter(new FileWriter(filenamePath));
            
            //Start writing to the output stream
            for(String res : input){
                bufferedWriter.write(res);
                bufferedWriter.newLine();
            }
//        	errorsF = new FileWriter(filename);
//          	             
//  	        for(String res : input){
//  	        	errorsF.write(res+"\r\n");
//  	        }
//        	
//  	        errorsF.close();
  	      
            
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            //Close the BufferedWriter
            try {
                if (bufferedWriter != null) {
                    bufferedWriter.flush();
                    bufferedWriter.close();
                }
//                errorsF.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}
